package com.hghivln.controller.doctor;

import com.hghivln.pojo.dto.PatientDto;
import com.hghivln.pojo.vo.AjaxResult;
import com.hghivln.service.PatientService;
import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;

@RestController
@RequestMapping("doctor/patient")
public class PatientController {

    @Reference
    private PatientService patientService;

    /**
     * 分页查询所有患者信息
     */
    @GetMapping("listPatientForPage")
    @HystrixCommand
    AjaxResult listPatientForPage(PatientDto patientDto) {
        return patientService.listPatientForPage(patientDto);
    }

    /**
     * 根据患者ID查询患者信息
     */
    @GetMapping("getPatientById/{patientId}")
    @HystrixCommand
    AjaxResult getPatientById(@PathVariable @Validated @NotBlank(message = "患者id不能为空") String patientId) {
        return patientService.selectPatientById(patientId);
    }

    /**
     * 根据患者ID查询患者的档案信息
     */
    @GetMapping("getPatientFileById/{patientId}")
    @HystrixCommand
    AjaxResult getPatientFileById(@PathVariable @Validated @NotNull(message = "患者id不能为空") String patientId) {
        return patientService.selectPatientFileById(patientId);
    }

    /**
     * 根据患者ID查询患者所有信息【基础，档案，病例】
     */
    @GetMapping("getPatientAllMessageByPatientId/{patientId}")
    @HystrixCommand
    AjaxResult getPatientAllMessageByPatientId(@PathVariable @Validated @NotNull(message = "患者id不能为空") String patientId) {
        return patientService.selectPatientFileById(patientId);
    }
}
